#include <vector>
#include <iostream>

using namespace std;

void merge(vector<int>& nums1, int m, vector<int>& nums2, int n)
{
	int index1 = 0;
	int index2 = 0;
	vector<int> temp;
	while (index1 != m || index2 != n)
	{
		if (index1 == m)
		{
			temp.push_back(nums2[index2]);
			index2++;
		}
		else if (index2 == n)
		{
			temp.push_back(nums1[index1]);
			index1++;
		}
		else if (nums1[index1] <= nums2[index2])
		{
			temp.push_back(nums1[index1]);
			index1++;
		}
		else
		{
			temp.push_back(nums2[index2]);
			index2++;
		}
	}
	for (size_t i = 0; i < m + n; i++)
	{
		nums1[i] = temp[i];
	}
}

int main()
{
	vector<int> num1 = { 1,2,3,0,0,0 };
	vector<int> num2 = { 2,5,6 };
	int m = 3;
	int n = 3;
	merge(num1, m, num2, n);
	for (size_t i = 0; i < m + n; i++)
	{
		cout << num1[i] << ',';
	}
	return 0;
}
